﻿

using System;
using System.Runtime.Serialization;
using System.Collections.Generic;
using COM.Rights.Model;



namespace COM.Rights.BLL
{
    public partial class TOUTTTUser
    {
        public bool SaveOUsByUser(string userGID, string ouIDS)
        {
            string ids = ouIDS.Trim(',');

            List<TOUTTTUserInfo> infos = new List<TOUTTTUserInfo>();

            foreach (string s in ids.Split(','))
            {
                if (!string.IsNullOrEmpty(s))
                {
                    TOUTTTUserInfo info = new TOUTTTUserInfo();
                    info.TOU_GID = s;
                    info.TUser_GID = userGID;
                    infos.Add(info);
                }
            }

            string filter = "TUser_GID=@TUser_GID";
            List<DBParameter> dps = new List<DBParameter>();
            dps.Add(new DBParameter("TUser_GID", userGID));
            this.Delete(filter, dps);
            this.Add(infos, "");

            return true;
        }
        public List<TOUTTTUserInfo> GetOUsByUser(string userID)
        {
            List<TOUTTTUserInfo> infos = new List<TOUTTTUserInfo>();
            string filter = "TUser_GID=@TUser_GID";
            List<DBParameter> dps = new List<DBParameter>();
            dps.Add(new DBParameter("TUser_GID", userID));
            infos = GetList("", filter, "", dps);
            return infos;
        }
        partial void OnBLLCreated() { ConfigName = "Rights"; }
    }
}